package com.kpf.springcloud.controller;

import com.kpf.springcloud.common.ResultJson;
import com.kpf.springcloud.pojo.PageResult;
import com.kpf.springcloud.service.FeignClientUserServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shiwen
 * @date 2021/3/10
 */
@RestController
@Api(value = "评论相关接口", description = "评论相关接口") //swagger接口配置
public class CommentConsumerController {

    @Autowired
    private FeignClientUserServer feignClientUserServer;

    @PostMapping("/consumer/comment/commentTopic")
    public ResultJson commentTopic(int topicId, String content){
        return feignClientUserServer.commentTopic(topicId, content);
    }

    @GetMapping("/consumer/comment/getCommentListByTopicId")
    public ResultJson<PageResult> getCommentListByTopicId(@ApiParam(value = "帖子id") @RequestParam(required = true) int topicId,
                                                          @ApiParam(value = "页码") @RequestParam(required = false, defaultValue = "1") int pageNum,
                                                          @ApiParam(value = "每页数量") @RequestParam(required = false, defaultValue = "5") int pageSize) {
        return feignClientUserServer.getCommentListByTopicId(topicId, pageNum, pageSize);
    }

    @PostMapping("/consumer/comment/deleteCommentById")
    public ResultJson deleteCommentById(int commentId) {
        return feignClientUserServer.deleteCommentById(commentId);
    }

    @GetMapping("/consumer/comment/getCommentList")
    public ResultJson<PageResult> getCommentList(@ApiParam(value = "页码") @RequestParam(required = false, defaultValue = "1") int pageNum,
                                                 @ApiParam(value = "每页数量") @RequestParam(required = false, defaultValue = "5") int pageSize) {
        return feignClientUserServer.getCommentList(pageNum, pageSize);
    }

}